<script setup lang="ts">
import { useStore } from "/@/cool";
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";

onLaunch(() => {
	console.log("App Launch");

	const { dict, user } = useStore();

	// 获取字典
	// dict.refresh();

	if (user.token) {
		// 获取登录用户信息
		// user.get();
	}
});

onShow(() => {
	console.log("App Show");
});

onHide(() => {
	console.log("App Hide");
});
onLaunch((options: any) => {
	console.log("App Launch");

	const { dict, user, tenant } = useStore();

	// 检查启动参数中是否包含租户ID
	if (options?.query && options.query.tenantId) {
		tenant.setTenantId(options.query.tenantId);
	}

	// 检查是否有 scene 参数
	if (options?.query && options.query.scene) {
		const scene = decodeURIComponent(options.query.scene);
		tenant.parseScene(scene);
	}

	//临时设置租户ID
	tenant.setTenantId("1");
	console.log("tenantId", tenant.tenantId);
	// 获取字典
	dict.refresh();

	if (user.token) {
		// 获取登录用户信息
		user.get();
	}
	
});
</script>

<style lang="scss">
</style>
